package com.wangjie.simple;

/**
 * @author jieshao
 * @date 2022/5/31 14:19
 *
 * 1732. 找到最高海拔
 */
public class Test18 {
    public static void main(String[] args) {
        int[] arr = {-5, 1, 5, 0, -7};
        int res = largestAltitude(arr);
        System.out.println(res);
    }

    public static int largestAltitude(int[] gain) {
        int sum = 0;
        int max = 0;
        for (int t : gain) {
            sum += t;
            max = Math.max(max, sum);
        }
        return max;
    }
}